package reflect;

import java.lang.reflect.Constructor;

public class ReflectDemo3
{
    public static void main(String[] args) throws Exception
    {

        Class cls = Class.forName("reflect.Person") ;
        // 利用构造器来创建新对象 （带参的）
        Constructor constructor = cls.getConstructor(String.class, int.class);
        Object bb = constructor.newInstance("bb酱", 22);
        System.out.println(bb.toString());

        Constructor constructor1 = cls.getConstructor(String.class);
        Object taoGe = constructor1.newInstance("杨伟涛哥");
        System.out.println(taoGe.toString());

    }
}
